package pkg

import (
	"time"

	"gitee.com/lyuanbo/stock-trade/internal/pkg/stock/constant"
)

// CheckOpen 是否开盘
func CheckOpen(Exchange constant.ExchangeType) bool {
	now := time.Now()
	hour, minute := now.Hour(), now.Minute()
	switch Exchange {
	case constant.ExchangeTypeSH, constant.ExchangeTypeSZ:
		return (hour == 9 && minute >= 30) || (hour >= 10 && hour < 11) ||
			(hour == 11 && minute < 30) || (hour >= 13 && hour < 15)
	case constant.ExchangeTypeHK:
		return (hour == 9 && minute >= 30) || (hour >= 10 && hour < 12) ||
			(hour >= 13 && hour < 16)
	}
	return false
}
